﻿@using OBUCare.Web.Infrastructure
@using OBUCare.Core.BL
@using OBUCare.Core.DataAccess;
@{
    ViewBag.Title = "SearchBy";

    ObuDropDownListHlper ddlHelper = new ObuDropDownListHlper();

    var operatorInfo = UIUtility.GetCurrentUser();

    var menuName = ViewData["menuName"];

    string AgentNo = UIUtility.getAgentByModule(operatorInfo, menuName.ToString());   
}
<link href="../../Content/tableCss.css" rel="stylesheet" type="text/css" />
@using (Html.BeginForm("Search", "Transaction", FormMethod.Post, new { @id = "searchForm" }))
{

    <div style="text-align: center">
        <table width="800">
            <tr>
                <td style="width: 200px; text-align: right">
                    流水单号：
                </td>
                <td style="width: 200px; text-align: left">
                    @Html.TextBox("txtTransferNo", "", new { @style = "width:230px;" })
                </td>
                <td style="width: 200px; text-align: right">
                    标签号：
                </td>
                <td style="width: 200px; text-align: left">
                    @Html.TextBox("txtObuNo", "", new { @style = "width:200px;", @MaxLength = "16" })
                </td>
            </tr>
            <tr>
                <td style="width: 200px; text-align: right">
                    客户编号：
                </td>
                <td style="width: 200px; text-align: left">
                    @Html.TextBox("txtUserNo", "", new { @style = "width:230px;" })
                </td>
                <td colspan="2" style="text-align: center">
                    <input type="button" id="btnSelect" value="查 询" />
                    @Html.Hidden("searchSql", "", new { @id = "searchSql" })
                    @Html.Hidden("AgentNo",AgentNo, new { @id = "AgentNo" })
                </td>
            </tr>
            <tr>
                <td colspan="4">
                </td>
            </tr>
        </table>
    </div>
}
<script type="text/javascript">
    $(function () {
        $('#btnSelect').bind("click", (function (e) {
            var orderNo = $('#txtTransferNo').val();
            var obuNo = $('#txtObuNo').val();
            var userNo = $('#txtUserNo').val();
            obuNo = $.trim(obuNo);
            orderNo = $.trim(orderNo);
            userNo = $.trim(userNo);
            if (obuNo.StringIsNullOrEmpty() && orderNo.StringIsNullOrEmpty() && userNo.StringIsNullOrEmpty()) {
                alert("请输入维修单号或标签号、客户编号！");
            }
            else if (obuNo.StringIsNullOrEmpty() == false && obuNo.length != 16) {
                alert("请输入完整的16位标签号！");
            }
            else if (userNo.StringIsNullOrEmpty() == false && userNo.length != 14) {
                alert("请输入完整的14位客户编号！");
            }
            else {
                var jdata = {
                    txtTransferNo: orderNo,
                    txtObuNo: obuNo,
                    txtUserNo: userNo
                };
                $.post("/Transaction/Search/", jdata,
                        function (data) {
                            // Successful requests get here
                            // Update the page elements
                            if (data.Success) {
                                var grid = $('#Grid').data('tGrid');
                                $('#searchSql').val(data.Sql)
                                //alert(data.Sql);
                                grid.rebind();
                            }
                            else {
                                alert("确认失败:" + data.message)
                            }
                        });
            }
        }));
    })
</script>
